package com.aaa.rent.service.impl;

import com.aaa.entity.Shop;
import com.aaa.rent.dao.ShopDao;
import com.aaa.rent.service.ShopService;
import com.aaa.vo.Result;
import com.aaa.vo.ShopVo;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author wys
 * @version 1.0
 * @date 2023/3/2 10:25
 * @author 荆豪峰
 * @version 1.0
 * #Date: 2023/3/1 17:03
 */
@Service
public class ShopServiceImpl extends ServiceImpl<ShopDao, Shop> implements ShopService {
    @Autowired
    private ShopDao shopDao;
    @Override
    public Result list(Integer currentPage, Integer pageSize, ShopVo shopVo) {
        PageHelper.startPage(currentPage, pageSize);
        List<ShopVo> sysDictTypes = shopDao.selectListName(shopVo.getSname());
        PageInfo<ShopVo> sysDictTypePageInfo = new PageInfo<>(sysDictTypes);
        return new Result(2000,"成功",sysDictTypePageInfo);

    }

    @Override
    public Result insert(Shop shop) {
        int insert = shopDao.insert(shop);
        return new Result(2000,"添加成功",insert);
    }

    @Override
    public Result delete(Integer id) {
        int i = shopDao.deleteById(id);
        return new Result(2000,"删除成功",i);
    }

    @Override
    public Result update(Shop shop) {
        int i = shopDao.updateById(shop);
        return new Result(2000,"修改成功",i);
    }

    @Override
    public Result selectShop() {
        List<Shop> shops = shopDao.selectList(null);
        return new Result(200,"查询成功",shops);
    }

}
